import { defineConfig,ConfigEnv,loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { resolve } from 'path';
import Unocss from 'unocss/vite'
import transformerDirective from "@unocss/transformer-directives";
const pathResolve = (dir: string) => {
	return resolve(__dirname, '.', dir);
};

const alias: Record<string, string> = {
	'/@': pathResolve('./src/'),
	'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
};


// https://vitejs.dev/config/
export default defineConfig((mode: ConfigEnv)=>{
	const env = loadEnv(mode.mode, process.cwd());
  return {
    resolve: { alias },
    plugins: [vue(),vueJsx(), Unocss({transformers: [transformerDirective()]})],
    server:{
      port:8088
    },
    base: mode.command === 'serve' ? './' : env.VITE_PUBLIC_PATH,
  }
  
})



